package com.starry.chat.logic.network

import com.starry.core.constant.GlobalConfig
import com.starry.core.logic.SharedOkHttpClient
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory

object ServiceCreator {

    private val retrofit: Retrofit by lazy {

        Retrofit.Builder()
            .baseUrl(GlobalConfig.getBaiduUrl())
            .addConverterFactory(GsonConverterFactory.create())
            .client(SharedOkHttpClient.getClient())
            .build()
    }

    inline fun <reified T> create(): T = create(T::class.java)

    fun <T> create(serviceClass: Class<T>): T = retrofit.create(serviceClass)
}